Skip to content

refactor: Convert legacy filter to be filter_query#128

Open
yuechao-qin wants to merge 1 commit intoycq/search-pipeline-run-created-byfrom
ycq/search-pipeline-run-legacy-filter
Open

refactor: Convert legacy filter to be filter_query#128
yuechao-qin wants to merge 1 commit intoycq/search-pipeline-run-created-byfrom
ycq/search-pipeline-run-legacy-filter

Conversation

@yuechao-qin
Copy link
Collaborator

@yuechao-qin yuechao-qin commented Feb 26, 2026

TL;DR

Refactored legacy filter query parameter to be filter_query JSON format.

Before

  • filter
    • GET /api/pipeline_runs/?filter=created_by:alice
    • GET /api/pipeline_runs/?filter=created_by:me
  • filter_query
    • GET /api/pipeline_runs/?filter_query={"and":[{"value_equals":{"key":"system/pipeline_run.created_by","value":"alice"}}]}

After

  • filter
    • Converts created_by:alice or created_by:me to be {"and":[{"value_equals":{"key":"system/pipeline_run.created_by","value":"alice"}}]}
  • filter_query no change.

What changed?

Functional

  • None. From a user perspective, filter and filter_query behaves the same.

Other

  • Replaced _build_filter_where_clauses function with _convert_legacy_filter_to_filter_query that converts legacy filter strings to filter_query JSON format
  • Modified build_list_filters to convert legacy filters to filter_query format and process them through the unified filter_query pipeline
  • Updated PageToken to store filter as None and use filter_query for all filtering operations
  • Added validation to reject empty created_by filter values with a clear error message
  • The "me" value in created_by:me filters is no longer resolved during conversion but handled downstream by _maybe_resolve_system_values

How to test?

uv run pytest tests/test_api_server_sql.py tests/test_filter_query_sql.py
  • Test legacy filter conversion with created_by:alice filters
  • Verify that created_by:me filters are converted but not immediately resolved
  • Confirm that empty created_by: filters raise ApiValidationError
  • Test pagination with legacy filters to ensure they're properly converted in page tokens
  • Verify that unsupported filter keys still raise NotImplementedError

Why make this change?

This change unifies the filter processing pipeline by converting legacy filters to the modern filter_query format, eliminating duplicate SQL generation logic and ensuring consistent behavior between legacy and modern filter formats.

@yuechao-qin yuechao-qin marked this pull request as ready for review February 26, 2026 14:56
@yuechao-qin yuechao-qin requested a review from Ark-kun as a code owner February 26, 2026 14:56
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-legacy-filter branch from f8f6e26 to 004fc05 Compare February 27, 2026 21:55
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-created-by branch from df1b586 to 05e42b2 Compare February 27, 2026 21:55
@yuechao-qin yuechao-qin changed the base branch from ycq/search-pipeline-run-created-by to graphite-base/128 February 28, 2026 10:24
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-legacy-filter branch from 004fc05 to 64651a0 Compare February 28, 2026 10:24
@yuechao-qin yuechao-qin changed the base branch from graphite-base/128 to ycq/search-pipeline-run-created-by February 28, 2026 10:24
@yuechao-qin yuechao-qin changed the base branch from ycq/search-pipeline-run-created-by to graphite-base/128 February 28, 2026 19:15
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-legacy-filter branch from 64651a0 to bb02751 Compare March 1, 2026 03:23
@yuechao-qin yuechao-qin changed the base branch from graphite-base/128 to ycq/search-pipeline-run-created-by March 1, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant